/*
 * @Description: 
 * @Version: 1.0
 * @Author: wenbin
 * @Date: 2021-04-13 16:02:53
 * @LastEditors: wenbin
 * @LastEditTime: 2021-05-31 11:02:02
 * @FilePath: /magus-plugin/examples/router/routerFilter.js
 * Copyright (C) 2021 wenbin. All rights reserved.
 */
import router from './index'
import magusUI from '../../packages/index'
import NProgress from "nprogress";

// const whiteList = ['/login', '/license'];

// to, from, next
router.beforeEach((to, from, next) => {
  if (magusUI.exportApi.commonUtils.getQueryVariable('projectname')) {
    let projectname = magusUI.exportApi.commonUtils.getQueryVariable('projectname')
    magusUI.exportApi.catchUtil.setSession('projectname', projectname)
  }
  NProgress.start();
  next();
  // if (catchUtils.getLocalItem('token')) {
  //   if (to.path === '/login') {
  //     next({
  //       path: '/'
  //     });
  //   } else {
  //     next();
  //   }
  // } else {
  //   if (whiteList.indexOf(to.path) !== -1) {
  //     next();
  //   } else {
  //     next('/login');
  //     NProgress.done();
  //   }
  // }

});

router.afterEach(() => {
  NProgress.done();
});